package com.kaibes.orm.core.listener;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.List;

import com.kaibes.orm.curd.Select;

public interface SelectListener<E> extends BaseListener {
    default void beforeSelect(Select select) throws Exception {
    }
    default void afterSelect(Select select, List<?> dataList) throws Exception {
    }
    @SuppressWarnings("unchecked")
    default boolean isSupports(Class<?> clazz) {
        Type superClass = getClass().getGenericSuperclass();
        Class<E> entityClass = (Class<E>) ((ParameterizedType) superClass).getActualTypeArguments()[0];
        return entityClass == clazz;
    }

}
